package com.cskt.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/*mybatis-plus自动填充处理器*/
@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("start inseert fill ...");
        this.strictInsertFill(metaObject,"creationDate", LocalDateTime::now,LocalDateTime.class);
        this.strictInsertFill(metaObject,"modifyDate",LocalDateTime::now,LocalDateTime.class);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("start update fill ...");
        this.strictUpdateFill(metaObject,"modifyDate",LocalDateTime::now,LocalDateTime.class);
    }
}
